package com.wanghe.leetcode.jianzhioffer;

import java.util.Arrays;

/**
 * 面试题01.02 判定是否互为字符重排
 * 题目链接: https://leetcode-cn.com/problems/check-permutation-lcci/
 */
public class Problem0102 {

    public static void main(String[] args) {

        String s1 = "";
        String s2 = "cab1";

        System.out.println(CheckPermutation(s1, s2));

    }

    private static boolean CheckPermutation(String s1, String s2) {

        String[] s1Split = s1.split("");
        Arrays.sort(s1Split);
        String newS1 = Arrays.toString(s1Split);

        String[] s2Split = s2.split("");
        Arrays.sort(s2Split);
        String newS2 = Arrays.toString(s2Split);

        if (newS1.equals(newS2)) {
            return true;
        }
        return false;

    }

}
